import 'dart:async';

import 'package:e_book/http/spider/spider_api.dart';
import 'package:e_book/model/activity.dart';
import 'package:e_book/model/book.dart';
import 'package:flutter/material.dart';

class HomeViewModel extends ChangeNotifier{
  List<Activity>? _activities;
  List<String>? _activiLabels;
  List<Book>? _books;

  List<Activity>? get activities => _activities;
  List<String>? get activiLabels => _activiLabels;
  List<Book>? get books => _books;

  set activities(List<Activity>?activities){
    _activities = activities;
    notifyListeners();
  }
  set activiLabels(List<String>?activiLabels){
    _activiLabels = activiLabels;
    notifyListeners();
  }
  set books(List<Book>?books){
    _books = books;
    notifyListeners();
  }

  Future getHomePageData() async {
    await SpiderApi.instance().fetchHomeData(
      activitiesCallback: (values)=> activities = values,
      activiLabelCallback: (values)=> activiLabels = values,
      booksCallback: (values)=> books = values,
    );
  }


}